/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Classe de base para DAO, que implementa operacoes basicas de
 * abrir/fechar conexao.
 * @author arruda
 */
public class BaseDAO {
    
    protected static String dbURL = "jdbc:postgresql://localhost:5432/dasbuchdb";
    protected static Connection conn = null;

    public static Connection getConn(){
        return conn;
    }
    public static void abrirConexao() {
        try {
            Class.forName("org.postgresql.Driver").newInstance();
            conn = DriverManager.getConnection(dbURL, "dasbuch", "dasbuch");

        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException e) {
            System.out.println(e.getMessage());
        }

    }

    public static void fecharConexao() {
        try {
            conn.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
            Logger.getLogger(PagamentoDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
}
